import requests
from bs4 import BeautifulSoup

url = 'http://top.hengyan.com/xuanhuan/'
html = requests.get(url)
soup = BeautifulSoup(html.text, "html.parser")


def generate_info():
    info = []
    for ul in soup.find_all('ul'):
        if ul.find_all('li', class_='num'):
            ha = []
            for li in ul.find_all('li', class_='num'):
                ha.append(li.string)
            for li in ul.find_all('li', class_='bookname'):
                if li.string is None:
                    for a in ul.find_all('a', target='_blank'):
                        ha.append(a.string)
                else:
                    ha.append(li.string)
                    ha.append('最新章节')
            for li in ul.find_all('li', class_='author'):
                ha.append(li.string)
            for li in ul.find_all('li', class_='length'):
                ha.append(li.string)
            for li in ul.find_all('li', class_='click'):
                ha.append(li.string)
            for li in ul.find_all('li', class_='update'):
                ha.append(li.string)
            info.append(ha)
    return info

